<?php
class CommonAction extends BaseAction{

	function _initialize() {
		// 		if($_SESSION[self::GLOBAL_SESSION_USER_KEY] == null){
		//$this->redirect("Login/");
		// 		}
		if(!empty($_REQUEST["currency"])){
			$_COOKIE["currency"] = $_REQUEST["currency"];
		}
		if(empty($_COOKIE["currency"])){
			$_COOKIE["currency"] = "USD";
		}
		$this->assign("IMG_URL", self::IMG_ACCESS_URL);
		$_SESSION["IMG_URL"] = self::IMG_ACCESS_URL;
		// 		if(!isset($_POST["currencies"])){
		//			$_POST["currencies"] = getDictMap("currency");
		// 		}
		$this->assign("shopping_cart", self::SHOPPING_CART);
	}


	public function getAllCategories(){
		$Category = D("Category");
		$allCategories = $Category->where("parent=0")->order("order_key desc")->relation(true)->select();

		for ($i = 0;$i < count($allCategories); $i++) {
			for ($j = 0;$j < count($allCategories[$i]["subCategories"]); $j++) {
				$tempProductCategoryMapping = D("ProductCategoryMapping");
				$allCategories[$i]["subCategories"][$j]["Products"] = $tempProductCategoryMapping->where("category_id=".$allCategories[$i]["subCategories"][$j]["id"])->select();
			}

		}
		return $allCategories;
	}

}